home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.1 KB | 143 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriDeb.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #define FWPRIDEB_H
-
- #ifndef SLDEBUG_H
- #include "SLDebug.h"
- #endif
-
-
- //========================================================================================
- // class FW_CDebugConsole
- //========================================================================================
-
- class FW_CDebugConsole
- {
- public:
-
- static FW_SDebugConsole* GetConsole();
- // Get the currently installed debug console
-
- static FW_SDebugConsole* SetConsole(FW_SDebugConsole* console);
- // Install a new debug console.
- // The prior debug console is returned.
-
- static void RequireMessage(const char* message);
- // Display the message, then throw a failure.
-
- static void AssertMessage(const char* message);
- // Display the message, then throw a failure.
-
- static void FatalMessage(const char* message);
- // Display the message, preferably without suspending execution.
-
- static void DebugMessage(const char* message);
- // Suspend normal execution and display the message.
-
- static void LogMessage(const char* message);
- // Display the message, preferably without suspending execution.
-
- static void Debugger();
- // Suspend normal execution without displaying a message
-
- static void SubclassResponsibility(const char* method);
- // Suspend normal execution displaying a message about the method
-
- private:
- FW_CDebugConsole();
- FW_CDebugConsole(const FW_CDebugConsole& debugConsole);
- FW_CDebugConsole& operator=(const FW_CDebugConsole& debugConsole);
- // No instances of this class.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CDebugConsole::GetConsole
- //----------------------------------------------------------------------------------------
-
- inline FW_SDebugConsole* FW_CDebugConsole::GetConsole()
- {
- return FW_PrivDebugConsole_GetConsole();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDebugConsole::SetConsole
- //----------------------------------------------------------------------------------------
-
- inline FW_SDebugConsole* FW_CDebugConsole::SetConsole(FW_SDebugConsole* console)
- {
- return FW_PrivDebugConsole_SetConsole(console);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_DEBUG_STRING
- // This macro expands its argument into a string. ANSI C hackery.
- // FW_DEBUG_STRING causes its argument to be expanded prior to calling
- // FW_DEBUG_STRING0. The latter macro converts its (expanded) argument
- // to a string.
- //----------------------------------------------------------------------------------------
-
- #define FW_DEBUG_STRING(x) FW_DEBUG_STRING0(x)
- #define FW_DEBUG_STRING0(x) #x
-
-
- //----------------------------------------------------------------------------------------
- // FW_REQUIRE
- // This check is always present in both the debug and release versions. Use it
- // when continuing execution would cause failure as in
- //
- // FW_REQUIRE(ptr != NULL);
- // ptr->Moby();
- //
- // FW_REQUIRE does an FW_THROW. Be sure that the throw is caught; don't let it
- // cross boundaries into/out of the part and the ODF shared library, as they will
- // frequently have been built using different exception handling packages (native
- // vs emulated).
- //
- // FW_ASSERT
- // This check is present *only* in debug versions. No throw is done.
- //----------------------------------------------------------------------------------------
-
-
- //----------------------------------------------------------------------------------------
- // The debugging macros are enabled only if debugging is turned on. The debug console
- // is always available in debug and release versions, but might be empty in the release
- // version.
- //----------------------------------------------------------------------------------------
-
- #ifdef FW_DEBUG
-
- #define FW_DEBUGGER() FW_CDebugConsole::Debugger()
- #define FW_DEBUG_MESSAGE(message) FW_CDebugConsole::DebugMessage(message)
- #define FW_LOG_MESSAGE(message) FW_CDebugConsole::LogMessage(message)
- #define FW_SUBCLASS_RESPONSIBILITY(method) \
- FW_CDebugConsole::SubclassResponsibility(#method); \
- ev->_major = (exception_type) -1
- #define FW_ASSERT(f) do if(!(f)) FW_CDebugConsole::AssertMessage( __FILE__ " @" FW_DEBUG_STRING(__LINE__) ": " #f); while (0)
- #define FW_REQUIRE(f) do if(!(f)) FW_CDebugConsole::RequireMessage(__FILE__ " @" FW_DEBUG_STRING(__LINE__) ": " #f); while (0)
-
- #else
-
- #define FW_DEBUGGER() ((void)0)
- #define FW_DEBUG_MESSAGE(message) ((void)0)
- #define FW_LOG_MESSAGE(message) ((void)0)
- #define FW_ASSERT(f) ((void)0)
- #define FW_SUBCLASS_RESPONSIBILITY(method) ((void)0)
- #define FW_REQUIRE(f) do if(!(f)) FW_CDebugConsole::RequireMessage(0) while (0)
-
- #endif
-
- #endif
-